#ifndef TWIDGET_H
#define TWIDGET_H

#include <QWidget>
#include <QAbstractButton>
#include <QPaintEvent>
#include <QPainter>
#include <QtDBus>

#include <stdlib.h>
#include <QString>
#include <QList>

struct QLauncher {
    QImage Icon;
    QString text, alert, apps;
    bool alarm, badge;
};

class QBadge : public QAbstractButton {
    Q_OBJECT
    public:
        QBadge(QString App="",QString Text="", QString Alert="" ,QImage Icon = QImage("resurces/pixmaps/Icons/apps.png"),bool Alarm = false, bool Badge = false,QWidget * parent = 0);
        ~QBadge();
        void setAlert(QString Alert);
        void setAlarm(bool Alarm);
        void setBadge(bool Badge);
        void setLaunch(bool Launch);


    protected:
        void paintEvent(QPaintEvent * event);

    private:
        QImage icon;
        QString text, app, alert;
        bool alarm, badge, stdLaunch;

        void fillEllipse (QPainter& p,int x, int y,int size,const QBrush& brush);
        void drawBadge (QPainter& p,int x, int y,int size,const QString& text,const QBrush& brush);
        void drawText (QPainter& p);
   private slots:
        void launch();
};

class QPhoneIcon : public QBadge {
    Q_OBJECT
    public:
        QPhoneIcon(QWidget * parent = 0);
        ~QPhoneIcon();
    private:
        int incomingCalls;
    private slots:
        void newCall();
};
class QMessageIcon : public QBadge {
    Q_OBJECT
    public:
        QMessageIcon(QWidget * parent = 0);
        ~QMessageIcon();
    private:
        int unreadMessages;
    private slots:
        void newMessage();
};

class QBar : public QWidget {
    Q_OBJECT
    public:
        QBar(QWidget * parent = 0);
        ~QBar();
        void addBadge(QLauncher  launcher);
        QBadge * appsIcon;

    protected:
        void paintEvent(QPaintEvent * event);

    private:
        QList <QBadge*> badgeList;
};

#endif // TWIDGET_H
